// Copyright 2011 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.


/**
 * @fileoverview An externs file that provides the public functionality of the
 * LayerManager.
 *
 * @author jasonstredwick@google.com (Jason Stredwick)
 */


/**
 * The LayerManager class stores all the data related to layers.
 * @constructor
 */
shellExtension.LayerManager = function() {};


/**
 * Interface for the log's signal.  Available for direct access.
 * @type {!Object.<string, function(!bite.common.log.Simple.Entry)>}
 */
shellExtension.LayerManager.prototype.onLogUpdated = {};


/**
 * @param {!bite.common.log.Simple.Entry} callback
 */
shellExtension.LayerManager.prototype.onLogUpdate.addListener =
    function(callback) {};

/**
 * @param {!bite.common.log.Simple.Entry} callback
 */
shellExtension.LayerManager.prototype.onLogUpdate.hasListener =
    function(callback) {};


/**
 * @param {!bite.common.log.Simple.Entry} callback
 */
shellExtension.LayerManager.prototype.onLogUpdate.removeListener =
    function(callback) {};


/**
 * Interface for the injection signal.  Available for direct access.
 * @type {!Object.<string, function()>}
 */
shellExtension.LayerManager.prototype.onInjectionComplete = {};


/**
 */
shellExtension.LayerManager.prototype.onInjectionComplete.addListener =
    function(callback) {};


/**
 */
shellExtension.LayerManager.prototype.onInjectionComplete.hasListener =
    function(callback) {};


/**
 */
shellExtension.LayerManager.prototype.onInjectionComplete.removeListener =
    function(callback) {};


/**
 * Add new layer(s) with the given id(s).  The callback will notify the user
 * when loading of the layer(s) is complete.  Duplicate layers are not allowed.
 * @param {!Array.<string>|string} ids The id or set of ids to be added.
 * @param {function(boolean)=} opt_callback The callback is called when the
 *     process terminates and passes along a boolean value of whether or not
 *     the process completed.
 */
shellExtension.LayerManager.prototype.add = function(ids, opt_callback) {};


/**
 * Changes the layer(s) ondemand flag to the given, valid state.  This function
 * is asynchronous because the change in setting could cause scripts to be
 * loaded immediately.
 * @param {string|!Array.<string>} ids The id(s) of the layer(s) to change.
 * @param {shellExtension.manifest.layer.State} state The new state.
 * @param {function(boolean)=} opt_callback The callback is called when the
 *     process terminates and passes along a boolean value of whether or not
 *     the entire process completed.
 */
shellExtension.LayerManager.prototype.changeOndemand =
    function(ids, state, opt_callback) {};


/**
 * Changes the layer(s) state to the given state.  This will only be
 * successful if the state is valid.
 * @param {string|!Array.<string>} ids The id(s) of the layer(s) to change.
 * @param {shellExtension.manifest.layer.State} state The new state.
 * @param {function(boolean)=} opt_callback The callback is called when the
 *     process terminates and passes along a boolean value of whether or not
 *     the entire process completed.
 */
shellExtension.LayerManager.prototype.changeState =
    function(ids, state, opt_callback) {};


/**
 * Clears all layer data and leaves the manager in the READY state.  The log
 * and injectionComplete signal are not modified and users do not have to
 * listen to them again.  Also, all user settings and additions will be lost.
 * @return {boolean} Whether or not the clear took place.  It can fail if the
 *     manager is locked.
 */
shellExtension.LayerManager.prototype.clear = function() {}


/**
 * Examines all layers and returns an array of objects where each object
 * contains details about the respective layer.  The layer load order is
 * represented in the order of the returned list.
 * @param {string=} opt_id An optional id if only one result is desired.
 * @return {!Array.<!shellExtension.data.LayerDetails>} An array of layer
 *     details.
 */
shellExtension.LayerManager.prototype.getLayerDetails = function(opt_id) {};


/**
 * Retrieve the status of the layer manager.
 * @return {shellExtension.status.Value} The status.
 */
shellExtension.LayerManager.prototype.getStatus = function() {};


/**
 * Allows users to manually inject content scripts into the given tab.
 * @param {Array.<string>|string|null} ids The id(s) of the layers to inject
 *     or null for all layers.
 * @param {number} tabId The id of the tab to insert into.
 * @param {string} url The tab's url to compare against in order to determine
 *     if that content script should be injected into that page.
 * @param {function(boolean)=} opt_callback The callback is called when the
 *     process terminates and passes along a boolean value of whether or not
 *     the entire process completed.
 */
shellExtension.LayerManager.prototype.inject = function(ids, tabId, url,
                                                        opt_callback) {};


/**
 * Returns whether or not the layer manager has cached settings.
 * @return {boolean} Is cached?
 */
shellExtension.LayerManager.prototype.isCached = function() {};


/**
 * If layers with the given ids are being managed, remove them.
 * @param {string|!Array.<string>} ids The id(s) of the layer(s) to remove.
 * @return {boolean} Whether or not the process completed.
 */
shellExtension.LayerManager.prototype.remove = function(ids) {};


/**
 * Loads the cached version of the layer state and reset the manager using
 * those values.
 * @param {function(boolean)=} opt_callback The callback is called when the
 *     process terminates and passes along a boolean value of whether or not
 *     the entire process completed.
 */
shellExtension.LayerManager.prototype.resetFromCache =
    function(opt_callback) {};


/**
 * Causes the given layer(s) to be reset to their initial state.
 * @param {Array.<string>|string|null} ids The id(s) of layer(s) to reset.  If
 *     null is given then all layers are reset.
 * @param {function(boolean)=} opt_callback The callback is called when the
 *     process terminates and passes along a boolean value of whether or not
 *     the entire process completed.
 */
shellExtension.LayerManager.prototype.resetLayer = function(ids,
                                                            opt_callback) {};

